﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Wandering
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)     //登录
        {
            var username = txtUid.Text;
            var password = txtPwd.Text;

            if (txtUid.Text !="" && txtPwd.Text !="")
            {
                var sql = string.Format("select * from Users where Username='{0}' and Password='{1}'", username, password);

                var dt = DBHelper.GetDataTable(sql);

                if (dt.Rows.Count == 1)
                {
                    MessageBox.Show("登录成功！");
                    MainForm mainForm = new MainForm();
                    this.Hide();
                    mainForm.Show();
                }
                else
                {
                    MessageBox.Show("登录失败！");
                }

            }
            else
            {
                MessageBox.Show("用户名和密码不能为空！");
            }

        }

        private void button2_Click(object sender, EventArgs e)     //注册
        {
            RegisterForm registerForm = new RegisterForm();
            registerForm.Show();

        }
    }
}
